<?php
class M_TourStyle extends Apps_Db_Table_Abstract {
    protected $_name = 'tour_style';

    public function listStyleShowHome($countryId = 1) {
        $q = $this->_db
                  ->select()
                  ->from('tour_style', null)
                  ->join('tour', 'tour.tour_style_id = tour_style.id', null)
                  ->join('country', 'country.id = tour.country_id', null)
                  ->where('country.id =? ', $countryId)
                  ->where('tour_style.show_home =? ', 1)
                  ->group('tour_style.id')
                  ->order('tour_style.sorting_number ASC')
                  ->columns(array('id' => 'tour_style.id'));

        if($this->getLang() == 'en') {
            $q->columns(array('tour_style_title' => 'tour_style.en_title'));
        } else $q->columns(array('tour_style_title' => 'tour_style.title'));

        return $q;
    }

    public function getTourStyleById($id) {
        $q = $this->_db
                    ->select()
                    ->from('tour_style', null)
                    ->where('tour_style.status =? ', 1)
                    ->where('tour_style.id =? ', $id)
                    ->columns(array(
                    		'id' 				  => 'tour_style.id',
	                        'meta_keyword'        => 'tour_style.meta_keyword',
	                        'meta_description'    => 'tour_style.meta_description',
	                        'header_title'        => 'tour_style.header_title'
                    	));

        if($this->getLang() == 'en') {
            $q->columns(array('tour_style_title' => 'tour_style.en_title'));
        } else $q->columns(array('tour_style_title' => 'tour_style.title'));

        return $q;
    }
}